package com.guigusuqi.payment.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.xiaoymin.knife4j.core.util.StrUtil;
import com.guigusuqi.commonutils.vo.Result;
import com.guigusuqi.payment.service.UserOrderRegistrationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

@Log4j2
@RestController
@Api(tags = {"wx-JSAPI支付"})
@RequestMapping
public class JSAPIController
{
    @Resource
    private UserOrderRegistrationService userOrderRegistrationService;

    @GetMapping("/preparePay/{registrationId}")
    @ApiOperation(value = "预支付,生成预订单id")
    public Result JSAPIPreparePay(@PathVariable("registrationId") String registrationId) throws Exception
    {
        return userOrderRegistrationService.JSAPIPreparePay(registrationId);
    }

    @RequestMapping(value = "/payNotify")
    public Result payNotify(@RequestBody Map body, HttpServletRequest request)
    {
        return userOrderRegistrationService.payNotify(body,request);
    }
}
